package com.quanyou.utils;

/**
 * Created by Thinkpad on 2016/4/12.
 */
public class SensitiveMixUtil {

    public static String maxName (String name) {
        if (name == null || "".equals(name)) {
            return "";
        }
        char [] nameC = new char[name.length()];
        for (int i = 0; i < name.length() ; i ++) {
            if (i == 1) {
                nameC[i] = '*';
            } else {
                nameC[i] = name.charAt(i);
            }
        }
        return new String(nameC);
    }

    public static String maxIdCardNo (String idCardNo) {
        if (idCardNo == null || "".equals(idCardNo)) {
            return "";
        }
        char [] idCardC = new char[idCardNo.length()];
        int length = idCardNo.length();
        for (int i = 0; i < length ; i ++) {
            if (i > 5 && i < length - 4) {
                idCardC[i] = '*';
            } else {
                idCardC[i] = idCardNo.charAt(i);
            }
        }
        return new String(idCardC);
    }

    public static String maxMobile (String mobile) {
        if (mobile == null || "".equals(mobile)) {
            return "";
        }
        char [] mobileC = new char[mobile.length()];
        int length = mobile.length();
        for (int i = 0; i < length ; i ++) {
            if (i > 2 && i < length - 4) {
                mobileC[i] = '*';
            } else {
                mobileC[i] = mobile.charAt(i);
            }
        }
        return new String(mobileC);
    }

    public static String mixBankcardNo (String bankcardNo) {
        if (bankcardNo == null || "".equals(bankcardNo)) {
            return "";
        }
        char [] idCardC = new char[bankcardNo.length()];
        int length = bankcardNo.length();
        for (int i = 0; i < length ; i ++) {
            if (i > 3 && i < length - 6) {
                idCardC[i] = '*';
            } else {
                idCardC[i] = bankcardNo.charAt(i);
            }
        }
        return new String(idCardC);
    }
}
